package com.thiswhyme.sentinel.server.instance2.controller;

import com.alibaba.csp.sentinel.annotation.SentinelResource;
import com.thiswhyme.common.response.ResponseVo;
import com.thiswhyme.sentinel.server.instance2.controller.dto.UserDto;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 注解+代码方式demo
 * Created by thiswhyme on 2020/8/16.
 */
@RestController
@RequestMapping("/code-demo/")
public class CodeDemoController {

    /**
     * 限流&熔断 -指定了资源名
     * @return
     */
    @SentinelResource(value = "user-info")
    @GetMapping("user-info")
    public ResponseVo<UserDto> queryUserInfo() {
        return ResponseVo.success(new UserDto().setUserId(666).setName("user-info"));
    }
}

